FROM centos:centos7.9.2009
LABEL version="nginx v1"
LABEL "emill"="415186314@qq.com"
RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone 
#ENV LANG=zh_CN.UTF-8
WORKDIR /usr/local/src
ENV NG_VERSION=nginx-1.25.1
RUN   curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo \
&& curl   -o /etc/yum.repos.d/epel-7.repo    https://mirrors.aliyun.com/repo/epel-7.repo \
&& sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \
    &&  yum -y install wget &&  wget http://nginx.org/download/$NG_VERSION.tar.gz && tar xzvf $NG_VERSION.tar.gz &&  yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel \
    && yum install -y pcre-devel libxslt-devel gd-devel GeoIP GeoIP-devel GeoIP-data libmaxminddb-devel \
    && yum clean all  && useradd -M -s /sbin/nologin nginx && mkdir  -p /apps
ADD  plugin/nginx-module-vts-0.2.1.tar.gz   /usr/local/src
ADD  plugin/ngx_http_geoip2_module.tar.gz  /usr/local/src
RUN  cd /usr/local/src/$NG_VERSION  &&  ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx  \
  --add-module=/usr/local/src/nginx-module-vts-0.2.1 \
  --add-module=/usr/local/src/ngx_http_geoip2_module \
  --with-stream --with-stream_ssl_module --with-file-aio \
  --with-http_ssl_module --with-http_realip_module \
  --with-http_addition_module --with-http_xslt_module \
  --with-http_image_filter_module --with-http_geoip_module \
  --with-http_sub_module --with-http_dav_module \
  --with-http_flv_module --with-http_mp4_module \
  --with-http_gunzip_module --with-http_gzip_static_module \
  --with-http_auth_request_module --with-http_random_index_module \
  --with-http_secure_link_module --with-http_degradation_module \
  --with-http_stub_status_module  && make -j 2 && make install  \
  && rm -rf  $NG_VERSION  \
  && mkdir  -p  /usr/local/nginx/default
COPY  conf/nginx.conf   /usr/local/nginx/conf/
COPY  conf/default.conf   /usr/local/nginx/default/
COPY  conf/auth_basic_user_file   /usr/local/nginx/conf/
COPY  plugin/GeoLite2-City.mmdb   /usr/local/nginx
COPY  plugin/GeoLite2-Country.mmdb   /usr/local/nginx
#ENV PATH=/usr/local/nginx/sbin:$PATH
WORKDIR /usr/local/nginx

#RUN ln -sf /dev/stdout /usr/local/nginx/logs/access.log \
#    && ln -sf /dev/stderr /usr/local/nginx/logs/error.log
#RUN ln -sf /dev/stdout /usr/local/nginx/logs/access80.log && \ 
#ln -sf /dev/stderr /usr/local/nginx/logs/error80.log
ENTRYPOINT ["/bin/sh", "-c", "/usr/local/nginx/sbin/nginx -g 'daemon off;'"]
#ENTRYPOINT ["/bin/sh", "-c", "envsubst < /usr/local/nginx/default/default.temp > /usr/local/nginx/default/default.conf  && nginx -g 'daemon off;'"]
#CMD envsubst < /usr/local/nginx/default/default.temp > /usr/local/nginx/default/default.conf  &&
#EXPOSE 80/tcp 
#ENTRYPOINT ["nginx"]
#CMD ["-g","daemon off;"]